<template>
  <h1>usercenter</h1>
</template>

<script>
  export default {
    name: "userCenter",
    data () {
      return {
        loginInfo: {
          user: '',
          password: ''
        },
        ruleInline: {
          user: [
            { required: true, message: '请输入用户名', trigger: 'blur' }
          ],
          password: [
            { required: true, message: '请输入密码.', trigger: 'blur' },
            { type: 'string', min: 6, message: '密码不能低于6位', trigger: 'blur' }
          ]
        }
      }
    },
    methods: {
      handleSubmit(name) {
        this.$refs[name].validate((valid) => {
          if (valid) {
            let loginObj = Object.assign({},this.loginInfo)
            this.$post(
              "/api/app/login",
              {
                ...loginObj
              }

            ).then(res=>{
              if(res.code===200){
                this.$Message.success('登录成功!');
                sessionStorage.setItem('AccessToken',res.token)
                this.$route.push("")
              }else {
                this.$Message.error('登录出错!');
              }

            }).catch( error=>{
              console.log("login error",error)
              this.$Message.error('登录出错!');
            })

          } else {
            this.$Message.error('验证出错');
          }
        })

      }
    }
  }
</script>

<style scoped>

</style>
